package com.digital.controller.admin;

import com.digital.entity.Class;
import com.digital.service.ClassService;
import com.digital.dto.ClassPageQueryDTO;
import com.digital.result.PageResult;
import com.digital.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "班级相关接口")
@RestController
@RequestMapping("/admin/class")
public class ClassController
{
    @Autowired
    private ClassService classService;

    /**
     * 班级分页查询
     * @param classPageQueryDTO
     * @return
     */
    @Operation(summary = "分页查询")
    @GetMapping("/page")
    public Result<PageResult> list(@ParameterObject ClassPageQueryDTO classPageQueryDTO)
    {
        PageResult pageResult = classService.getList(classPageQueryDTO);
        return Result.success(pageResult);
    }

    /**
     * 添加班级
     * @param classEntity
     * @return
     */
    @Operation(summary = "添加班级")
    @PostMapping("/add")
    public Result add(@RequestBody Class classEntity)
    {
        classService.addClass(classEntity);
        return Result.success();
    }
}
